/**
 * @author wjj
 */

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.util.Iterator;
import java.util.Map;

public class FormDataGenerator {

    private static final ObjectMapper om = new ObjectMapper();

    /**
     * 根据 JSON Schema 生成默认的 formData
     *
     * @param schema JSON Schema
     * @return 生成的 formData
     */
    public static ObjectNode generateFormData(JsonNode schema) {
        if (schema == null || !schema.isObject()) {
            return null;
        }

        ObjectNode formData = om.createObjectNode();

        // 遍历 properties
        JsonNode properties = schema.get("properties");
        if (properties != null && properties.isObject()) {
            Iterator<Map.Entry<String, JsonNode>> fields = properties.fields();
            while (fields.hasNext()) {
                Map.Entry<String, JsonNode> field = fields.next();
                String fieldName = field.getKey();
                JsonNode fieldSchema = field.getValue();

                // 根据字段类型生成默认值
                formData.set(fieldName, generateFieldValue(fieldSchema));
            }
        }

        return formData;
    }

    /**
     * 根据字段的 Schema 生成默认值
     *
     * @param fieldSchema 字段的 Schema
     * @return 生成的默认值
     */
    private static JsonNode generateFieldValue(JsonNode fieldSchema) {
        if (fieldSchema == null || !fieldSchema.isObject()) {
            return null;
        }

        // 理论上type肯定存在, 为了健壮, 设定当type不存在时, 指定为string: 当为对象或者list时,可能会导致类型不对. 当有嵌套时,可能不会执行嵌套的逻辑.
        String type = fieldSchema.has("type") ? fieldSchema.get("type").asText() : "string";

        // 处理对象类型
        if ("object".equals(type) && fieldSchema.has("properties")) {
            return generateFormData(fieldSchema);
        }

        // 处理数组类型
        if ("array".equals(type)) {
            ArrayNode arrayNode = om.createArrayNode();
            int minItems = fieldSchema.has("minItems") ? fieldSchema.get("minItems").asInt() : 0;
            JsonNode itemsSchema = fieldSchema.get("items");

            for (int i = 0; i < minItems; i++) {
                arrayNode.add(generateFieldValue(itemsSchema));
            }
            return arrayNode;
        }

        // 处理基本类型
        switch (type) {
            case "string":
                if (fieldSchema.has("format") && ("date".equals(fieldSchema.get("format").asText()) || "date-time".equals(fieldSchema.get("format").asText()))) {
                    // 日期类型返回空字符串
                    return om.getNodeFactory().textNode("");
                }
                // 默认字符串
                return om.getNodeFactory().textNode("");
            case "number":
            case "integer":
                // 数字类型返回 null
                return om.getNodeFactory().nullNode();
            case "boolean":
                // 布尔类型返回 false
                return om.getNodeFactory().booleanNode(false);
            default:
                // 其他类型返回 null
                return om.getNodeFactory().nullNode();
        }
    }

    public static void main(String[] args) throws Exception {
        // 示例 JSON Schema
        String schemaJson = "{\"title\":\"报价\",\"description\":\"产品报价\",\"properties\":{\"map_policy\":{\"title\":\"最低广告价格显示\",\"description\":\"选择一个。\",\"examples\":[\"政策 9\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"最低广告价格显示\",\"description\":\"选择一个。\",\"editable\":true,\"hidden\":false,\"examples\":[\"政策 9\"],\"type\":\"string\",\"enum\":[\"policy_1\",\"policy_10\",\"policy_11\",\"policy_2\",\"policy_3\",\"policy_4\",\"policy_5\",\"policy_6\",\"policy_7\",\"policy_8\",\"policy_9\"],\"enumNames\":[\"Policy 1\",\"Policy 10\",\"Policy 11\",\"Policy 2\",\"Policy 3\",\"Policy 4\",\"Policy 5\",\"Policy 6\",\"Policy 7\",\"Policy 8\",\"Policy 9\"]}},\"additionalProperties\":false}},\"purchasable_offer\":{\"title\":\"可购买的报价\",\"description\":\"提供可购买的报价信息\",\"examples\":[\"EUR\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\",\"currency\",\"audience\"],\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"map_price\":{\"title\":\"可购买报价最低广告价格\",\"description\":\"该属性表示产品的可购买报价最低广告价格\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"schedule\":{\"title\":\"可购买报价最低广告定价计划\",\"description\":\"该属性表示产品的可购买报价最低广告定价计划\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"value_with_tax\":{\"title\":\"最低广告价格\",\"description\":\"提供最低广告价格\",\"editable\":true,\"hidden\":false,\"examples\":[\"259.99\"],\"type\":\"number\"}},\"additionalProperties\":false}}},\"additionalProperties\":false}},\"currency\":{\"title\":\"貨幣\",\"description\":\"选择相应的货币\",\"default\":\"USD\",\"editable\":false,\"hidden\":true,\"examples\":[\"USD\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"USD\"],\"enumNames\":[\"USD\"]}]},\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"our_price\":{\"title\":\"可购买报价我方价格\",\"description\":\"该属性表示对该产品的我方可购买报价\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[\"schedule\"],\"properties\":{\"schedule\":{\"title\":\"可购买报价我方价格计划\",\"description\":\"该属性指示产品的可购买报价我方价格计划\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[\"value_with_tax\"],\"properties\":{\"value_with_tax\":{\"title\":\"您的价格\",\"description\":\"指明向目标买家群体提供的商品基本价格\",\"editable\":true,\"hidden\":false,\"examples\":[\"9.00\"],\"type\":\"number\"}},\"additionalProperties\":false}}},\"additionalProperties\":false}},\"minimum_seller_allowed_price\":{\"title\":\"可购买报价最低卖方接受的价格\",\"description\":\"该属性表示产品的可购买报价最低卖方接受的价格\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"schedule\":{\"title\":\"可购买报价最低卖方接受的价格计划\",\"description\":\"该属性表示产品的可购买报价、最低卖方接受价格、计划\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"value_with_tax\":{\"title\":\"卖方允许的最低价格\",\"description\":\"提供卖方允许的最低价格\",\"editable\":true,\"hidden\":false,\"examples\":[\"259.99\"],\"type\":\"number\"}},\"additionalProperties\":false}}},\"additionalProperties\":false}},\"maximum_seller_allowed_price\":{\"title\":\"可购买报价最高卖方接受的价格\",\"description\":\"该属性表示产品的可购买报价最高卖方接受的价格\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"schedule\":{\"title\":\"可购买报价最高卖方接受的价格计划\",\"description\":\"该属性表示产品的可购买报价、最高卖方接受的价格、计划\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"value_with_tax\":{\"title\":\"卖方允许的最高价格\",\"description\":\"提供卖方允许的最高价格\",\"editable\":true,\"hidden\":false,\"examples\":[\"259.99\"],\"type\":\"number\"}},\"additionalProperties\":false}}},\"additionalProperties\":false}},\"discounted_price\":{\"title\":\"可购买报价折扣价格\",\"description\":\"该属性表示产品的可购买报价、折扣价\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[\"schedule\"],\"properties\":{\"schedule\":{\"title\":\"可购买报价折扣价计划\",\"description\":\"该属性表示产品的可购买报价折扣价格计划\",\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[\"end_at\",\"start_at\",\"value_with_tax\"],\"properties\":{\"end_at\":{\"title\":\"销售截止日期\",\"description\":\"用销售价格替代产品标准价格的最后一天；产品的标准价格将在销售截止日期的凌晨 0:00 后显示。\",\"editable\":true,\"hidden\":false,\"examples\":[\"2017-07-01\"],\"type\":\"string\",\"oneOf\":[{\"type\":\"string\",\"format\":\"date\"},{\"type\":\"string\",\"format\":\"date-time\"}]},\"start_at\":{\"title\":\"销售开始日期\",\"description\":\"用销售价格替代产品标准价格的第一天；销售价格将在销售开始日期的凌晨 0:00 后显示。\",\"editable\":true,\"hidden\":false,\"examples\":[\"2017-06-30\"],\"type\":\"string\",\"oneOf\":[{\"type\":\"string\",\"format\":\"date\"},{\"type\":\"string\",\"format\":\"date-time\"}]},\"value_with_tax\":{\"title\":\"销售价格\",\"description\":\"您提供的待售产品的价格。\",\"editable\":true,\"hidden\":false,\"examples\":[\"219.99\"],\"type\":\"number\"}},\"additionalProperties\":false}}},\"additionalProperties\":false}},\"start_at\":{\"title\":\"可购买报价开始于\",\"description\":\"该属性表示产品的可购买报价、起始时间\",\"type\":\"object\",\"required\":[],\"properties\":{\"value\":{\"title\":\"提供发布日期\",\"description\":\"您的价格的开始日期\",\"editable\":true,\"hidden\":false,\"examples\":[\"2017-06-30\"],\"type\":\"string\",\"oneOf\":[{\"type\":\"string\",\"format\":\"date\"},{\"type\":\"string\",\"format\":\"date-time\"}]}},\"additionalProperties\":false},\"end_at\":{\"title\":\"可购买报价结束于\",\"description\":\"该属性表示产品的可购买报价结束于\",\"type\":\"object\",\"required\":[],\"properties\":{\"value\":{\"title\":\"停售日期\",\"description\":\"您的价格的截止日期\",\"editable\":true,\"hidden\":false,\"examples\":[\"2017-07-01\"],\"type\":\"string\",\"oneOf\":[{\"type\":\"string\",\"format\":\"date\"},{\"type\":\"string\",\"format\":\"date-time\"}]}},\"additionalProperties\":false},\"audience\":{\"editable\":false,\"hidden\":true,\"type\":\"string\",\"enum\":[\"ALL\"],\"enumNames\":[\"Sell on Amazon\"]},\"quantity_discount_plan\":{\"title\":\"可购买的企业优惠批量折扣计划\",\"description\":\"为商品企业价格提供并定义批量折扣计划。\",\"examples\":[\"计划批量价格类型： 固定；计划等级批量下限： 5；计划等级批量价格： 10\"],\"type\":\"array\",\"minItems\":1,\"maxItems\":0,\"items\":{\"type\":\"object\",\"required\":[\"schedule\"],\"properties\":{\"schedule\":{\"title\":\"计划\",\"description\":\"说明用于定义安排的批量折扣计划的详细信息，例如日期、定价类型。\",\"examples\":[\"批量价格起始日期： 2024 年 6 月 30 日；批量价格结束日期： 2024 年 7 月 1 日\"],\"type\":\"array\",\"minItems\":1,\"items\":{\"type\":\"object\",\"required\":[\"discount_type\",\"levels\"],\"properties\":{\"discount_type\":{\"title\":\"批发价格类型\",\"description\":\"说明批量价格类型是否为“固定”、每个批量阈值的当地货币价格或商品企业价格的百分比。\",\"editable\":true,\"hidden\":false,\"examples\":[\"固定、百分比\"],\"type\":\"string\",\"enum\":[\"fixed\",\"percent\"],\"enumNames\":[\"fixed\",\"percent\"]},\"levels\":{\"title\":\"等级\",\"description\":\"批量折扣计划日程等级\",\"examples\":[\"批量折扣计划日程等级\"],\"type\":\"array\",\"minItems\":1,\"maxItems\":5,\"items\":{\"type\":\"object\",\"required\":[\"lower_bound\",\"value\"],\"properties\":{\"lower_bound\":{\"title\":\"批量阈值（下限）\",\"description\":\"说明获得折扣所需的最低购买量。如果达到批量阈值，将适用于所有单位。\",\"editable\":true,\"hidden\":false,\"examples\":[\"5、10\"],\"type\":\"integer\",\"minimum\":0},\"value\":{\"title\":\"批发价格（固定价格/百分比折扣）\",\"description\":\"说明每个批量阈值的批发价格，或根据每个批量阈值的企业价格提供的折扣百分比。\",\"editable\":true,\"hidden\":false,\"examples\":[\"10、20\"],\"type\":\"number\",\"minimum\":0}},\"additionalProperties\":false}}},\"additionalProperties\":false}}},\"additionalProperties\":false}}},\"additionalProperties\":false}},\"condition_note\":{\"title\":\"新旧程度说明\",\"description\":\"用于具体说明该商品新旧程度的描述性文本。\",\"examples\":[\"商品外盒边角有破损\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\",\"language_tag\"],\"items\":{\"type\":\"object\",\"required\":[\"language_tag\",\"value\"],\"properties\":{\"language_tag\":{\"default\":\"en_US\",\"editable\":false,\"examples\":[\"英语 (美国)\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"en_US\"],\"enumNames\":[\"英语 (美国)\"]}],\"ui:hidden\":true},\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"出价条件说明\",\"description\":\"提供说明项目实际情况的描述性文字\",\"editable\":true,\"hidden\":false,\"examples\":[\"左侧面板有小凹痕。\"],\"type\":\"string\",\"maxLength\":2204}},\"additionalProperties\":false}},\"condition_type\":{\"title\":\"提供条件类型\",\"description\":\"提供产品的实际条件类型\",\"examples\":[\"全新\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"提供条件类型\",\"description\":\"提供产品的实际条件类型\",\"editable\":false,\"hidden\":false,\"examples\":[\"全新\"],\"type\":\"string\",\"enum\":[\"used_like_new\",\"used_acceptable\",\"used_good\",\"used_very_good\",\"club_club\",\"new_oem\",\"new_open_box\",\"collectible_like_new\",\"collectible_acceptable\",\"collectible_good\",\"collectible_very_good\",\"new_new\",\"refurbished_refurbished\"],\"enumNames\":[\"二手 - 像新的一样\",\"二手-可接受\",\"二手–好\",\"二手–非常好\",\"俱乐部\",\"全新-OEM\",\"全新-开箱\",\"收藏品-像新的一样\",\"收藏品-可接受\",\"收藏品-好\",\"收藏品-非常好\",\"新\",\"翻新的\"]}},\"additionalProperties\":false}},\"skip_offer\":{\"title\":\"跳过报价\",\"description\":\"指明是否应跳过该报价，是否不应创建可购买的报价。值为“是”表示不会创建任何报价。\",\"examples\":[\"是\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"跳过报价\",\"description\":\"指明是否应跳过该报价，是否不应创建可购买的报价。值为“是”表示不会创建任何报价。\",\"editable\":true,\"hidden\":false,\"examples\":[\"是\"],\"type\":\"boolean\",\"enum\":[true,false],\"enumNames\":[\"是\",\"没有\"]}},\"additionalProperties\":false}},\"merchant_shipping_group\":{\"title\":\"配送模板\",\"description\":\"该商品使用的配送模板。卖家可以在“配送设置”页面创建和管理配送模板。卖家可以自定义模板名称，如“大件商品配送模板”、“促销配送模板”\",\"examples\":[\"大件商品配送模板\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"商船集团\",\"description\":\"出价的船舶配置组。卖方通过船舶设置 UI 创建和管理船舶配置组。\",\"editable\":true,\"hidden\":false,\"examples\":[\"重型产品、NCR 大型设备交付\"],\"type\":\"string\",\"maxLength\":100}},\"additionalProperties\":false}},\"list_price\":{\"title\":\"不含税价目表\",\"description\":\"给出不含税的产品标价。  标价通常是指制造商建议零售价（MSRP）、推荐零售价（RRP）或建议零售价（SRP）。这不是发行价或成本价。\",\"examples\":[\"67 CNY\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\",\"currency\"],\"items\":{\"type\":\"object\",\"required\":[\"currency\",\"value\"],\"properties\":{\"currency\":{\"title\":\"价目表货币\",\"description\":\"选择相应的货币\",\"editable\":false,\"hidden\":true,\"examples\":[\"CNY\"],\"type\":\"string\",\"enum\":[\"USD\"],\"enumNames\":[\"USD\"]},\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"不含税价目表\",\"description\":\"提供商品的定价（不含税）。定价是制造商、供应商或卖家提供的商品建议零售价。这不是报价或成本价。\",\"editable\":true,\"hidden\":false,\"examples\":[\"67\"],\"type\":\"number\",\"minimum\":0,\"maxLength\":20,\"multipleOf\":0.01}},\"additionalProperties\":false}},\"main_offer_image_locator\":{\"title\":\"主商品图片定位器\",\"description\":\"提供图片的位置\",\"examples\":[\"供稿\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"media_location\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"media_location\":{\"title\":\"主图片的地址\",\"description\":\"产品的交付主图所在的链接地址\",\"editable\":true,\"hidden\":false,\"examples\":[\"http://www.companyname.com/images/1250.offer.jpg\"],\"type\":\"string\",\"format\":\"uri\",\"pattern\":\"^(https?|s3)://\"}},\"additionalProperties\":false}},\"gift_options\":{\"title\":\"礼品选项\",\"description\":\"提供礼品卡选项\",\"examples\":[\"是\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[],\"properties\":{\"can_be_messaged\":{\"title\":\"可以提供礼品信息\",\"description\":\"如果您可以打印礼品信息与项目，请在此注明。  如果留白，默认为“false”\",\"editable\":true,\"hidden\":false,\"examples\":[\"“TRUE”\"],\"type\":\"boolean\",\"enum\":[true,false],\"enumNames\":[\"是\",\"没有\"]},\"can_be_wrapped\":{\"title\":\"表示礼品包装可用\",\"description\":\"如果你为一个项目做礼品包装，请在此注明。  如果留白，默认为“false”\",\"editable\":true,\"hidden\":false,\"examples\":[\"“TRUE”\"],\"type\":\"boolean\",\"enum\":[true,false],\"enumNames\":[\"是\",\"没有\"]},\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true}},\"additionalProperties\":false}},\"product_tax_code\":{\"title\":\"产品税码\",\"description\":\"输入 Amazon.com 向您提供的产品税码\",\"examples\":[\"A_GEN_NOTAX\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"产品税码\",\"description\":\"输入 Amazon.com 向您提供的产品税码\",\"editable\":true,\"hidden\":false,\"examples\":[\"A_GEN_NOTAX\"],\"type\":\"string\",\"maxLength\":949}},\"additionalProperties\":false}},\"other_offer_image_locator_5\":{\"title\":\"其他商品图片定位器\",\"description\":\"提供图片的位置及来源\",\"examples\":[\"供稿\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"media_location\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"media_location\":{\"title\":\"其他图片的地址\",\"description\":\"其他产品图片的链接地址。当客户点击查看与产品相关的其他视图时，这些图片将显示在详细信息页面上。\",\"editable\":true,\"hidden\":false,\"examples\":[\"http://www.companyname.com/images/1250.other1.jpg\"],\"type\":\"string\",\"format\":\"uri\",\"pattern\":\"^(https?|s3)://\"}},\"additionalProperties\":false}},\"other_offer_image_locator_4\":{\"title\":\"其他商品图片定位器\",\"description\":\"提供图片的位置\",\"examples\":[\"供稿\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"media_location\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"media_location\":{\"title\":\"其他图片的地址\",\"description\":\"其他产品图片的链接地址。当客户点击查看与产品相关的其他视图时，这些图片将显示在详细信息页面上。\",\"editable\":true,\"hidden\":false,\"examples\":[\"http://www.companyname.com/images/1250.other1.jpg\"],\"type\":\"string\",\"format\":\"uri\",\"pattern\":\"^(https?|s3)://\"}},\"additionalProperties\":false}},\"other_offer_image_locator_3\":{\"title\":\"其他商品图片定位器\",\"description\":\"提供图片的位置\",\"examples\":[\"供稿\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"media_location\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"media_location\":{\"title\":\"其他图片的地址\",\"description\":\"其他产品图片的链接地址。当客户点击查看与产品相关的其他视图时，这些图片将显示在详细信息页面上。\",\"editable\":true,\"hidden\":false,\"examples\":[\"http://www.companyname.com/images/1250.other1.jpg\"],\"type\":\"string\",\"format\":\"uri\",\"pattern\":\"^(https?|s3)://\"}},\"additionalProperties\":false}},\"other_offer_image_locator_2\":{\"title\":\"其他商品图片定位器\",\"description\":\"提供图片的位置\",\"examples\":[\"供稿\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"media_location\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"media_location\":{\"title\":\"其他图片的地址\",\"description\":\"其他产品图片的链接地址。当客户点击查看与产品相关的其他视图时，这些图片将显示在详细信息页面上。\",\"editable\":true,\"hidden\":false,\"examples\":[\"http://www.companyname.com/images/1250.other1.jpg\"],\"type\":\"string\",\"format\":\"uri\",\"pattern\":\"^(https?|s3)://\"}},\"additionalProperties\":false}},\"other_offer_image_locator_1\":{\"title\":\"其他商品图片定位器\",\"description\":\"提供图片的位置\",\"examples\":[\"供稿\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"media_location\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"media_location\":{\"title\":\"其他图片的地址\",\"description\":\"其他产品图片的链接地址。当客户点击查看与产品相关的其他视图时，这些图片将显示在详细信息页面上。\",\"editable\":true,\"hidden\":false,\"examples\":[\"http://www.companyname.com/images/1250.other1.jpg\"],\"type\":\"string\",\"format\":\"uri\",\"pattern\":\"^(https?|s3)://\"}},\"additionalProperties\":false}},\"fulfillment_availability\":{\"title\":\"配送可用性\",\"description\":\"对于使用 Amazon 配送服务的商家，请提供相关的物流信息。\",\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"fulfillment_channel_code\"],\"items\":{\"type\":\"object\",\"required\":[\"fulfillment_channel_code\"],\"properties\":{\"fulfillment_channel_code\":{\"title\":\"物流渠道代码\",\"description\":\"对于使用亚马逊物流服务的商家，指定将使用哪个物流网络。指定除 DEFAULT 以外的值将取消商家交付的产品。对于商家交付的产品，应将此字段留空。\",\"editable\":true,\"hidden\":false,\"examples\":[\"AMAZON_NA\"],\"type\":\"string\",\"enum\":[\"AMAZON_NA\",\"DEFAULT\"],\"enumNames\":[\"AMAZON_NA\",\"DEFAULT\"]},\"quantity\":{\"title\":\"数量\",\"description\":\"输入您可出售的商品数量。这是您当前的库存承诺（取整数）\",\"editable\":true,\"hidden\":false,\"examples\":[\"152\"],\"type\":\"integer\",\"minimum\":0},\"lead_time_to_ship_max_days\":{\"title\":\"处理时间\",\"description\":\"以天为单位，提供收到商品订单到发货的时间\",\"editable\":true,\"hidden\":false,\"examples\":[\"5\"],\"type\":\"integer\",\"minimum\":0,\"maximum\":30},\"restock_date\":{\"title\":\"重新库存日期\",\"description\":\"产品补货日期\",\"editable\":true,\"hidden\":false,\"examples\":[\"2020-05-05\"],\"type\":\"string\",\"oneOf\":[{\"type\":\"string\",\"format\":\"date\"},{\"type\":\"string\",\"format\":\"date-time\"}]},\"is_inventory_available\":{\"title\":\"始终有货\",\"description\":\"始终有货是除数量之外的另一种库存表示方式，表示库存永远不会耗尽。启用或禁用将打开或关闭此功能。请注意，提供时不能指定数量。\",\"editable\":true,\"hidden\":false,\"examples\":[\"已禁用\"],\"type\":\"boolean\",\"enum\":[true,false],\"enumNames\":[\"已启用\",\"已禁用\"]}},\"additionalProperties\":false}},\"merchant_release_date\":{\"title\":\"发售日期\",\"description\":\"卖家可以在该输入项内为商品提前设定可出售日期（在此日期之前该商品可见，但无法被购买）。\",\"examples\":[\"2004-05-01\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"发售日期\",\"description\":\"卖家可以在该输入项内为商品提前设定可出售日期（在此日期之前该商品可见，但无法被购买）。\",\"editable\":true,\"hidden\":false,\"examples\":[\"2004-05-01\"],\"type\":\"string\",\"oneOf\":[{\"type\":\"string\",\"format\":\"date\"},{\"type\":\"string\",\"format\":\"date-time\"}]}},\"additionalProperties\":false}},\"max_order_quantity\":{\"title\":\"命令的最大数量。\",\"description\":\"对于指定商品，请说明每个买家在单笔订单中所能购买的最大商品数量。\",\"examples\":[\"3\"],\"type\":\"array\",\"minItems\":1,\"minUniqueItems\":1,\"maxUniqueItems\":1,\"selectors\":[\"marketplace_id\"],\"items\":{\"type\":\"object\",\"required\":[\"value\"],\"properties\":{\"marketplace_id\":{\"default\":\"ATVPDKIKX0DER\",\"editable\":false,\"examples\":[\"Amazon.com\"],\"type\":\"string\",\"anyOf\":[{\"type\":\"string\"},{\"type\":\"string\",\"enum\":[\"ATVPDKIKX0DER\"],\"enumNames\":[\"Amazon.com\"]}],\"ui:hidden\":true},\"value\":{\"title\":\"最大订单数量\",\"description\":\"整数。\",\"editable\":true,\"hidden\":false,\"examples\":[\"75\"],\"type\":\"integer\",\"minimum\":1}},\"additionalProperties\":false}}}}";

        // 解析 JSON Schema
        ObjectMapper objectMapper = new ObjectMapper();
        JsonNode schema = objectMapper.readTree(schemaJson);

        // 生成 formData
        ObjectNode formData = FormDataGenerator.generateFormData(schema);

        // 打印生成的 formData
        System.out.println(formData.toPrettyString());
    }
}